﻿function onAddCustomMenuItems(menu) 
{
  menu.AddItem(ADD_REMOVE_PROMPT, 0, addRemoveRings);
  var subMenu = menu.AddPopup("Change Ring Color");
  for( var i=0; i<RING_TYPE.length; i++ )
    subMenu.AddItem(RING_TYPE[i], 0, onSubMenuClicked);
  
  reinitializeSubMenus(subMenu);
}

function onSubMenuClicked(i)
{
  colorChanger.value = i;
  changeColors();
}

function reinitializeSubMenus(subMenu)
{ 
  var ringIsDisplayed;
  for( var i=0; i<RING_TYPE.length; i++ )
  {
    ringIsDisplayed = false;
    for (var j=0; j<Rings.length; j++)
    {
      if (RING_TYPE[i] == Rings[j].ringName)
        ringIsDisplayed = true;  
    }
  
    if (ringIsDisplayed == false)
    {
      subMenu.SetItemStyle(RING_TYPE[i], gddMenuItemFlagGrayed);
    }
  }
}

